package com.hhcn.sort;

import com.hhcn.sort.model.Person;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created by Administrator on 2018/5/24.
 */
public class SortReduce extends Reducer<Person, Text, Text, Text> {
    Text lastName = new Text();

    @Override
    public void reduce(Person key, Iterable<Text> values, Context context)
            throws IOException, InterruptedException {

        lastName.set(key.getLastName());

        for (Text firstName : values) {
            context.write(lastName, firstName);
        }
    }
}
